import Redis from 'ioredis';

// 创建一个 Redis 客户端
const redis = new Redis({
  host: 'localhost',
  port: 6379,
  connectTimeout: 3000,
  db:1,
});

async function run() {
  try {
    while (true) {
      const val = await redis.blpop("myList",3);
      console.log(`receive: ${val?.[1]}`)
    }
  } catch (error) {
    console.error('Error:', error);
  } finally {
    // 关闭连接
    redis.quit();
  }
}

// 运行主函数
run();

console.log("done")
